package training.project.app.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import training.project.app.domain.FlightClient;
import training.project.app.repository.FlightClientDao;
import training.project.app.service.UserService;
import training.project.app.service.FlightClientService;
import training.project.app.service.FlightService;

@Service
@Transactional
public class FlightClientServiceImpl implements FlightClientService
	{
		@Autowired
		private FlightClientDao flightClientRepository;
		@Autowired
		private FlightService flightService;
		@Autowired
		private UserService clientService;

		@Override
		public FlightClient getFlightClientById(Integer id)
			{
				return flightClientRepository.findById(id);
			}

		public void saveFlightClient(FlightClient client)
			{
				flightClientRepository.save(client);
			}

		@Override
		public void updateFlightClient(FlightClient client)
			{
				flightClientRepository.update(client);
			}

		@Override
		public void delete(FlightClient client)
			{
				flightClientRepository.delete(client);
			}

		@Override
		public List<FlightClient> getFlightClients(Integer clientId)
			{
				return flightClientRepository.getFlightClients(clientId);
			}

		@Override
		public void purchaseFlight(FlightClient flightClient)
			{
				
				flightClientRepository.purchaseFlight(flightClient);			
			}
			

		@Override
		public void cancelFlight(FlightClient flightClient)
			{
				flightClientRepository.delete(flightClient);
			}
	}
